package gateway

import (
	"com.cyt.common/library/sms/internal"
	"github.com/gogf/gf/frame/g"
	"time"
)

type Gateway struct {
	To *internal.PhoneNumber
	Message *internal.Message
}
var TimeOut = g.Cfg().GetDuration("sms.timeout")

type Driver interface {
	New(gateway *Gateway) (Channel, error)
}

type Channel interface {
	Send() (map[string]interface{})
}

func Get(endpoint string, params map[string]interface{}, headers map[string]string) string {
	return g.Client().Header(headers).SetTimeout(TimeOut * time.Second).GetContent(endpoint, params)
}

func Post(endpoint string, params map[string]interface{}, headers map[string]string) string {
	return g.Client().Header(headers).SetTimeout(TimeOut * time.Second).PostContent(endpoint, params)
}

func PostJson(endpoint string, params map[string]interface{}, headers map[string]string) string {
	return g.Client().ContentJson().Header(headers).SetTimeout(TimeOut * time.Second).PostContent(endpoint, params)
}